1. Field of the Invention
The present invention relates to microprocessors. More specifically, the present invention relates to microprocessors that have more than one mode of operation, and switch between the modes to accommodate software designed for one of the modes.
2. Description of Related Art
Microprocessor technology has evolved rapidly over the past decade. Microprocessors that were considered advanced ten years ago have been successively supplanted by several new generations of microprocessors. The new generations of microprocessors are much more powerful than the older generations, having greatly expanded functions and capabilities, and much faster operating speeds. Software written for the new microprocessors can take advantage of many of the new functions; however, older and less complex software written for previous generations of microprocessors is still in common use and commercially available. Most computer users do not want to discard their old software whenever the manufacturer develops a new model, and in fact, there may be advantages to using the old method of operation for some special purposes. Thus, microprocessor designers typically design their new microprocessors to be compatible with older software.
In order to ensure that older software can run on newer microprocessors, some manufacturers design the microprocessor with several available modes, with at least one of the modes having the operational characteristics of the earlier microprocessor. For example, the INTEL corporation manufactured the original 8086 microprocessor a number of years ago. Since then, this microprocessor has evolved progressively into the 80286, the i386.TM., and then the i486.TM. microprocessors. These later generation microprocessors have several available modes of operation. In order to provide compatibility with programs written for the 8086 microprocessor, the later generations can operate in a "real-address" mode, typically called the real mode, that has the operational characteristics and the data structures of the 8086 microprocessor, as well as in other modes, such as a "protected" mode in which the newer microprocessor's capabilities can be more fully utilized with greater operational capabilities and different data structures.
For some types of software, it is useful to switch between modes of operation during program execution. An example of a program that switches between the protected mode and real mode is a memory manager. The memory manager may begin operation in the real mode, switch to the protected mode at some point in its operation to access data with an address over 1 Megabyte, copy blocks of data, and then return to the real mode for further processing.
Upon start-up, the registers of the 8086 microprocessor and its progeny are initialized to the real mode configuration by microcode. After initialization, software is executed which sets up data structures appropriate to the real mode. However, if instead of the real mode, the application software uses the protected mode, then that software sets a flag enabling the protected mode's capabilities. The program then sets up the data structures appropriate to the protected mode, and switches the microprocessor to the protected mode of operation. The designers of the 80286 microprocessor did not envision anyone wanting to switch from the protected mode to the real mode; and therefore no provision was made for this type of switching. In other words, the architecture of the 80286 microprocessor did not support switching from the protected mode to the real mode.
However, some computer manufacturers using the 80286 microprocessor, such as IBM, wanted a capability to switch from the protected mode to the real mode, and developed a method to accomplish the switch by including another device that asserted the reset pin in order to reset and re-initialize the microprocessor as if it had just started up. However, there are some problems associated with simply asserting the reset pin. In later microprocessors that include additional features like an internal cache and an internal floating point unit, such as the i486.TM. microprocessor, asserting the reset pin also re-initializes the cache, thereby destroying the contents of the cache memory. Furthermore, the contents of the registers in the floating point unit (which was physically separate in the 8086, 80286, and i368.TM. microprocessor) were also re-initialized (and therefore destroyed) by a reset with self-test, although the floating point registers' contents were maintained by a reset without self-test.
The internal cache memory, which was first introduced in the i468.TM. microprocessor, is used in all modes of microprocessor operation: the real mode, the virtual 8086 mode, and the protected mode, among others. The cache includes memory, internal to the microprocessor, that speeds up processing of data and instructions by storing certain data and instructions recently retrieved from main memory. A purpose of the cache is to minimize retrieval time and write time for frequently used data and instructions. Caching may be divided into two types: write-through, or write-back. Write-back caches generally have greater performance in a microprocessor. Both types function similarly in reading data from them; however, when writing to them, write-through caching updates both the cache and main memory, while in write-back caching, the cache contents are updated without writing to main memory. In write-back caching, writing the updated results to main memory occurs only when specific operations are performed, for example when new cache lines are allocated after the cache is already full. Thus, if the contents of a write-back cache were to be re-initialized, the updated data would be lost unless it is written back to memory or saved elsewhere. Write-back caching, although more difficult to implement, is useful because it saves microprocessor time that would be wasted unnecessarily writing to main memory each time that the cache is updated. Furthermore, write-back caching minimizes the traffic on the bus, freeing the bus for other communications.
A problem arises if the reset pin is asserted in order to get to the real mode of operation, particularly if a write-back cache has been implemented in the microprocessor, for faster performance over a write-through cache. In a full reset, the cache is re-initialized and all its contents are lost, including any changes that were made. If the cache is the write-back type, these changes were not written to main memory, and therefore the contents of main memory would contain incorrect data, a result that is unacceptable. If the cache contents were written to memory in order to update memory with correct data, then a large performance degradation would occur. Substantial time would be lost in writing the contents of the entire cache. Furthermore, the loss of cache contents in re-initialization may cause a slowdown of operating speed because the re-initialized cache had contained frequently used data and instructions. Although not all of the cache information will be used; it is possible that a substantial portion of the cache would be used again. This cache would need to be refilled during the microprocessor's normal operations, a task that consumes substantial microprocessor time unnecessarily. For these and other reasons, it is desirable to leave the contents of the cache intact while switching between modes.
In summary, it would be an improvement to provide a microprocessor that can quickly and straightforwardly switch between the real mode and the protected mode, while retaining the contents of a write-back cache without the need to write the contents to memory. It would also be an improvement if the microprocessor could save the contents of the registers in the floating point unit for compatibility with microprocessors that utilize a separate floating point unit.